/*
 * @lc app=leetcode.cn id=728 lang=cpp
 *
 * [728] 自除数
 */

// @lc code=start
class Solution
{
public:
  vector<int> selfDividingNumbers(int left, int right)
  {
    vector<int> ans;
    for (; left <= right; ++left)
      if (IsSelfDividingNum(left))
        ans.push_back(left);
    return ans;
  }

  bool IsSelfDividingNum(int num)
  {
    for (int tmp = num; tmp != 0; tmp /= 10) {
      int r = tmp % 10;
      if (r == 0 || num % r != 0)
        return false;
    }
    return true;
  }
};
// @lc code=end
